Skip to contentSkip to conversation

Change in openvpn[master]: Clarify operator precedence in a & b ? c : d

Openvpn-devel Superseded flichtenheld (Code Review) 2 participants 9 messages Apr 5 – Apr 8 1 message not in the archive

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1775421558000.Ia153e0de888c0ee21199b192f3471ce4c08cb5c7@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email

to review the following change.

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Clarify operator precedence in a & b ? c : d

As suggested by cppcheck.

Change-Id Ia153e0de888c0ee21199b192f3471ce4c08cb5c7

---
M src/openvpn/error.h
M src/openvpn/options.c
M src/openvpnserv/common.c
M src/openvpnserv/interactive.c

4 files changed, 5 insertions(+), 5 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/19/1619/1

src/openvpn/error.h +1 -1
index 62389af..03d880f 100644
@@ -399,7 +399,7 @@
 static inline msglvl_t
 nonfatal(const msglvl_t err)
 {
-    return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
+    return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err;
 }
 
 static inline int
src/openvpn/options.c +2 -2
index 186b2d2..e4905c9 100644
@@ -7043,12 +7043,12 @@
         if (options->routes->flags & RG_REROUTE_GW)
         {
             setenv_int(es, "route_redirect_gateway_ipv4",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
         if (options->routes_ipv6 && (options->routes_ipv6->flags & RG_REROUTE_GW))
         {
             setenv_int(es, "route_redirect_gateway_ipv6",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
 #ifdef _WIN32
         /* we need this here to handle pushed --redirect-gateway */
src/openvpnserv/common.c +1 -1
index f60e2f2..7fc8c14 100644
@@ -276,7 +276,7 @@
 
         const WCHAR *mesg[] = { msg[0], msg[1] };
         ReportEvent(hEventSource,
-                    flags & MSG_FLAGS_ERROR ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
+                    (flags & MSG_FLAGS_ERROR) ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
                     0,
                     EVT_TEXT_2,
                     NULL,
src/openvpnserv/interactive.c +1 -1
index a2f9f09..ace25b9 100644
@@ -3410,7 +3410,7 @@
     ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
     ea[0].Trustee.TrusteeType = TRUSTEE_IS_UNKNOWN;
     ea[0].Trustee.ptstrName = (LPWSTR)svc_user->User.Sid;
-    ea[1].grfAccessPermissions = READ_CONTROL | SYNCHRONIZE | PROCESS_VM_READ | SYNCHRONIZE
+    ea[1].grfAccessPermissions = READ_CONTROL | PROCESS_VM_READ | SYNCHRONIZE
                                  | PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION;
     ea[1].grfAccessMode = SET_ACCESS;
     ea[1].grfInheritance = NO_INHERITANCE;

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email )

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Patch Set 1: Code-Review-2

(2 comments)

Patchset:

PS1:
stray change to interactive.c?

File src/openvpnserv/interactive.c:

http://gerrit.openvpn.net/c/openvpn/+/1619/comment/d7d72371_81303fee?usp=email :
PS1, Line 3414: | PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION;
this looks very unrelated

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Mon, 06 Apr 2026 07:25:03 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello cron2, plaisthos,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email

to look at the new patch set (#2).

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Clarify operator precedence in a & b ? c : d

As suggested by cppcheck.

Change-Id Ia153e0de888c0ee21199b192f3471ce4c08cb5c7

---
M src/openvpn/error.h
M src/openvpn/options.c
M src/openvpnserv/common.c

3 files changed, 4 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/19/1619/2

src/openvpn/error.h +1 -1
index 62389af..03d880f 100644
@@ -399,7 +399,7 @@
 static inline msglvl_t
 nonfatal(const msglvl_t err)
 {
-    return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
+    return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err;
 }
 
 static inline int
src/openvpn/options.c +2 -2
index 186b2d2..e4905c9 100644
@@ -7043,12 +7043,12 @@
         if (options->routes->flags & RG_REROUTE_GW)
         {
             setenv_int(es, "route_redirect_gateway_ipv4",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
         if (options->routes_ipv6 && (options->routes_ipv6->flags & RG_REROUTE_GW))
         {
             setenv_int(es, "route_redirect_gateway_ipv6",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
 #ifdef _WIN32
         /* we need this here to handle pushed --redirect-gateway */
src/openvpnserv/common.c +1 -1
index f60e2f2..7fc8c14 100644
@@ -276,7 +276,7 @@
 
         const WCHAR *mesg[] = { msg[0], msg[1] };
         ReportEvent(hEventSource,
-                    flags & MSG_FLAGS_ERROR ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
+                    (flags & MSG_FLAGS_ERROR) ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
                     0,
                     EVT_TEXT_2,
                     NULL,

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: cron2, plaisthos.

flichtenheld has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email )

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Patch Set 2:

(1 comment)

File src/openvpnserv/interactive.c:

http://gerrit.openvpn.net/c/openvpn/+/1619/comment/b1e21d64_851be6a3?usp=email :
PS1, Line 3414: | PROCESS_TERMINATE | PROCESS_QUERY_INFORMATION;

Quoted 1 line

this looks very unrelated

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: cron2 <[email protected]...>
Gerrit-Comment-Date: Tue, 07 Apr 2026 20:06:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: cron2 <[email protected]...>

#5 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email )

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Patch Set 2: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 2
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Tue, 07 Apr 2026 20:52:19 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#6 lore raw

PATCH v2 1/1 Clarify operator precedence in a & b ? c : d

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

As suggested by cppcheck.

Change-Id Ia153e0de888c0ee21199b192f3471ce4c08cb5c7

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1619
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1619
This mail reflects revision 2 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpn/error.h +1 -1
index 62389af..03d880f 100644
@@ -399,7 +399,7 @@
 static inline msglvl_t
 nonfatal(const msglvl_t err)
 {
-    return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
+    return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err;
 }
 
 static inline int
src/openvpn/options.c +2 -2
index 186b2d2..e4905c9 100644
@@ -7043,12 +7043,12 @@
         if (options->routes->flags & RG_REROUTE_GW)
         {
             setenv_int(es, "route_redirect_gateway_ipv4",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
         if (options->routes_ipv6 && (options->routes_ipv6->flags & RG_REROUTE_GW))
         {
             setenv_int(es, "route_redirect_gateway_ipv6",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
 #ifdef _WIN32
         /* we need this here to handle pushed --redirect-gateway */
src/openvpnserv/common.c +1 -1
index f60e2f2..7fc8c14 100644
@@ -276,7 +276,7 @@
 
         const WCHAR *mesg[] = { msg[0], msg[1] };
         ReportEvent(hEventSource,
-                    flags & MSG_FLAGS_ERROR ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
+                    (flags & MSG_FLAGS_ERROR) ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
                     0,
                     EVT_TEXT_2,
                     NULL,
#7 lore raw

[Openvpn-devel] [PATCH applied] Re: Clarify operator precedence in a & b ? c : d

Highly appreciated... (and oops, two of them are mine). No actual change in functionality, just ensuring a clear and shared understanding between compiler and humans reading the code... stared-at-code, test compiled, BB ran client side tests.

Your patch has been applied to the master branch.

commit 1491fc8e05b01e65aba8b50499407d9af0424d69

Author: Frank Lichtenheld
Date:   Tue Apr 7 22:52:28 2026 +0200
     Clarify operator precedence in a & b ? c : d

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1619
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg36545.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#8 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#3) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Clarify operator precedence in a & b ? c : d

As suggested by cppcheck.

Change-Id Ia153e0de888c0ee21199b192f3471ce4c08cb5c7

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1619
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36545.html

---
M src/openvpn/error.h
M src/openvpn/options.c
M src/openvpnserv/common.c

3 files changed, 4 insertions(+), 4 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/19/1619/3

src/openvpn/error.h +1 -1
index 1198994..3b742d7 100644
@@ -397,7 +397,7 @@
 static inline msglvl_t
 nonfatal(const msglvl_t err)
 {
-    return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
+    return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err;
 }
 
 static inline int
src/openvpn/options.c +2 -2
index 713dcf4..b8d0f5a 100644
@@ -7044,12 +7044,12 @@
         if (options->routes->flags & RG_REROUTE_GW)
         {
             setenv_int(es, "route_redirect_gateway_ipv4",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
         if (options->routes_ipv6 && (options->routes_ipv6->flags & RG_REROUTE_GW))
         {
             setenv_int(es, "route_redirect_gateway_ipv6",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
 #ifdef _WIN32
         /* we need this here to handle pushed --redirect-gateway */
src/openvpnserv/common.c +1 -1
index f60e2f2..7fc8c14 100644
@@ -276,7 +276,7 @@
 
         const WCHAR *mesg[] = { msg[0], msg[1] };
         ReportEvent(hEventSource,
-                    flags & MSG_FLAGS_ERROR ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
+                    (flags & MSG_FLAGS_ERROR) ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
                     0,
                     EVT_TEXT_2,
                     NULL,

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#9 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email )

Change subject: Clarify operator precedence in a & b ? c : d
......................................................................

Clarify operator precedence in a & b ? c : d

As suggested by cppcheck.

Change-Id Ia153e0de888c0ee21199b192f3471ce4c08cb5c7

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1619
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg36545.html

---
M src/openvpn/error.h
M src/openvpn/options.c
M src/openvpnserv/common.c

3 files changed, 4 insertions(+), 4 deletions(-)
src/openvpn/error.h +1 -1
index 1198994..3b742d7 100644
@@ -397,7 +397,7 @@
 static inline msglvl_t
 nonfatal(const msglvl_t err)
 {
-    return err & M_FATAL ? (err ^ M_FATAL) | M_NONFATAL : err;
+    return (err & M_FATAL) ? (err ^ M_FATAL) | M_NONFATAL : err;
 }
 
 static inline int
src/openvpn/options.c +2 -2
index 713dcf4..b8d0f5a 100644
@@ -7044,12 +7044,12 @@
         if (options->routes->flags & RG_REROUTE_GW)
         {
             setenv_int(es, "route_redirect_gateway_ipv4",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
         if (options->routes_ipv6 && (options->routes_ipv6->flags & RG_REROUTE_GW))
         {
             setenv_int(es, "route_redirect_gateway_ipv6",
-                       options->routes->flags & RG_BLOCK_LOCAL ? 2 : 1);
+                       (options->routes->flags & RG_BLOCK_LOCAL) ? 2 : 1);
         }
 #ifdef _WIN32
         /* we need this here to handle pushed --redirect-gateway */
src/openvpnserv/common.c +1 -1
index f60e2f2..7fc8c14 100644
@@ -276,7 +276,7 @@
 
         const WCHAR *mesg[] = { msg[0], msg[1] };
         ReportEvent(hEventSource,
-                    flags & MSG_FLAGS_ERROR ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
+                    (flags & MSG_FLAGS_ERROR) ? EVENTLOG_ERROR_TYPE : EVENTLOG_INFORMATION_TYPE,
                     0,
                     EVT_TEXT_2,
                     NULL,

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1619?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia153e0de888c0ee21199b192f3471ce4c08cb5c7
Gerrit-Change-Number: 1619
Gerrit-PatchSet: 3
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>